﻿Imports Microsoft.VisualBasic
Imports System.Data.OleDb
Imports System.Data

Public Class clsConnect
    Private con As New OleDbConnection
    Public strConnectionString As String

    Sub New()
        'Dim oConfig As System.Configuration.Configuration = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/GHBankKYC")

        'If (oConfig.ConnectionStrings.ConnectionStrings.Count > 0) Then
        '    Try
        '        strConnString = oConfig.ConnectionStrings.ConnectionStrings("dsConnect").ConnectionString
        '    Catch

        '    End Try
        'Else
        '    Throw New ApplicationException("Could not load the database")
        'End If
        Try
            strConnectionString = ConfigurationManager.ConnectionStrings("GHBankAMLConnectionString").ConnectionString
            ' strConnString = "Provider=OraOLEDB.Oracle;Data Source=GHBKYC;User Id=KYCADMIN;Password=oracle;Unicode=True"
        Catch
            Throw New ApplicationException("Could not load the database")
        End Try

        'Dim oConfig As System.Configuration.Configuration

        'oConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/GHBankAML")

        'If (oConfig.ConnectionStrings.ConnectionStrings.Count > 0) Then
        '    Try
        '        strConnectionString = oConfig.ConnectionStrings.ConnectionStrings("GHBankAMLConnectionString").ConnectionString
        '    Catch
        '        strConnectionString = "Data Source=localhost; initial catalog=NeoPerFmAMS;user id=dbuser;password=dbuser;"
        '    End Try
        'Else
        '    Throw New ApplicationException("Could not load the database")
        'End If
    End Sub

    Public Function cn() As OleDbConnection
        If con.State = Data.ConnectionState.Closed Then
            con.ConnectionString = strConnectionString
        End If

        Return con
    End Function
End Class
